<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" src="scripts/boot.js"></script>
</head>
<body style="border: 0px; margin: 0px; padding: 0px;width: 100%;height: 100%">
<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
    <table style="width:100%;">
        <tr>
            <td style="width:100%;">
            <sec:authorize url='/set_basic_salary.do'>
            	<a class="mini-button" iconCls="icon-add" onclick="openSetBasic()">新增</a>
            </sec:authorize>
            <sec:authorize url='/staff_delete.do'>
				<a class="mini-button" iconCls="icon-remove" onclick="onRemove()">删除已选</a>
			</sec:authorize>
			<sec:authorize url='/update_basic_salary.do'>
				<a class="mini-button" iconCls="icon-edit" onclick="onEdit()">修改</a>
			</sec:authorize>
            </td>
            <td style="white-space:nowrap;">
                <input id="name" class="mini-textbox" emptyText="请输入姓名" style="width:150px;" onenter="onKeyEnter"/>   
                <a class="mini-button" onclick="search()">查询</a>
            </td>
        </tr>
    </table>
</div>
<div class="mini-fit" >
	<div id="datagrid0921" class="mini-datagrid " idField="id" pageSize="20" allowAlternating="true" 
	allowCellSelect="true" multiSelect="true" url="staff_page.do" style="width:100%;height: 100%">
		<div property="columns">
			<div type="indexcolumn"></div>
			<div type="checkcolumn"></div>
			<div field="dept" width="25%" headerAlign="center" align="center">部门</div>
			<div field="platformName" width="25%" headerAlign="center" align="center">中心</div>
			<div field="groupName" width="25%" headerAlign="center" align="center">组</div>
			<div field="name" width="25%" headerAlign="center" align="center">姓名</div>
			<div field="positionName" width="25%" headerAlign="center" align="center">职务</div>
			<div field="basic" width="25%" dataType="currency" headerAlign="center" align="center">基本工资（元）</div>
		</div>
	</div>
</div>
<script type="text/javascript">
mini.parse();
var grid = mini.get("datagrid0921");
grid.load();

// 新建
function openSetBasic() {
	mini.open({
        url: "set_basic_salary.do",
        allowResize:false,
        title: "新增员工基本工资", width: 400, height: 360,
        ondestroy: function (action) {
        	if(action == 'succ'){
        		mini.showMessageBox({
                    title: "提示",
                    showModal:false,
                    iconCls: "mini-messagebox-info",
                    message: "保存成功！",
                    timeout: 3000,
                    x: 'right',
                    y: 'bottom'
                });
	            grid.reload();
        	}
        }
    });
}

//修改
function onEdit() {
    var row = grid.getSelecteds();
    if (row.length > 0) {
    	if(row.length > 1) {
    		mini.alert('请选择一条数据进行修改!'); return;
    	} else {
	        mini.open({
	            url: "update_basic_salary.do",
	            allowResize:false,
	            title: "修改员工基本工资", width: 400, height: 260,
	            onload: function () {
	                var iframe = this.getIFrameEl();
	                iframe.contentWindow.SetData(row[0]);
	            },
	            ondestroy: function (action) {
	            	if(action == 'succ'){
	            		mini.showMessageBox({
	                        title: "提示",
	                        showModal:false,
	                        iconCls: "mini-messagebox-info",
	                        message: "修改成功",
	                        timeout: 3000,
	                        x: 'right',
	                        y: 'bottom'
	                    });
	                	grid.reload();
	            	}
	            }
	        });
    	}
    } else {
        mini.alert("请选中一条记录");
    }
    
}

//删除
function onRemove() {
    var rows = grid.getSelecteds();
    var arr = new Array();
    $.each(rows,function(i,v){
    	arr.push(v.id);
    });
    var rids = arr.join("-");
    if (rows.length > 0) {
    	mini.confirm("确定删除选中记录？", "删除",
               function (action) {
                   if (action == "ok") {
                   	grid.loading("操作中，请稍后......");
                       $.post(
                       	"staff_delete.do",
                       	{id:rids},
                       	function(data){
                       		mini.showMessageBox({
                                   title: "提示",
                                   showModal:false,
                                   iconCls: "mini-messagebox-info",
                                   message: "已删除",
                                   timeout: 3000,
                                   x: 'right',
                                   y: 'bottom'
                               });
                       		grid.reload();
                       	},"json");
                   }
               });
    } else {
        mini.alert("请选中一条记录");
    }
}

function search() {
	var name = mini.get("name").getValue();
	grid.load({name: name});
}
</script>
</body>
</html>